#!/usr/bin/env python3
# encoding: utf-8

"""
@version: 1.0
@author: 周永波
@file: serializableRet.py
@time: 2020/8/14 9:32
"""
from collections import OrderedDict

from pyparsing import basestring


# class DictSerializable(object):
#     def as_dict(self,*args):
#         result = OrderedDict()
#         keys=args or self.__mapper__.c.keys()
#         for key in keys:
#             if hasattr(self,key):
#                 obj=getattr(self, key)
#                 if isinstance(obj,basestring):
#                     value=obj
#                 elif isinstance(obj,int) or isinstance(obj,long) or isinstance(obj,float):
#                     value=obj
#                 elif isinstance(obj,Decimal):
#                     value=str(obj)
#                 elif isinstance(obj,types.choice.Choice):
#                     value=obj.code
#                 elif isinstance(obj,datetime):
#                     value=obj.strftime('%Y-%m-%d %M:%H:%S')
#                 elif isinstance(obj,date):
#                     value=obj.strftime('%Y-%m-%d')
#                 else:
#                     raise Exception('不支持系列化[%s]类型!' % type(obj))
#                 result[key] = value
#
#         return result